pub enum VertexAttributeSize {
    Unknown,
    U32,
    F32,
    Vec2,
    Vec3,
    Vec4,
    Float32,
    Float32x2,
    Float32x3,
    Float32x4,
}

impl From<&str> for VertexAttributeSize {
    fn from(str: &str) -> Self {
        match str {
            "u32" => { VertexAttributeSize::U32 }
            "f32" => { Self::F32 }
            "vec2<f32>" => { Self::Vec2 }
            "vec3<f32>" => { Self::Vec3 }
            "vec4<f32>" => { Self::Vec4 }
            "float32" => { Self::Float32 }
            "float32x2" => { Self::Float32x2 }
            "float32x3" => { Self::Float32x3 }
            "float32x4" => { Self::Float32x4 }
            _ => { Self::Unknown }
        }
    }
}


impl From<VertexAttributeSize> for wgpu::VertexFormat {
    fn from(attr: VertexAttributeSize) -> Self {
        match attr {
            VertexAttributeSize::Unknown => wgpu::VertexFormat::Float32,
            VertexAttributeSize::U32 => wgpu::VertexFormat::Uint32,
            VertexAttributeSize::F32 => wgpu::VertexFormat::Float32,
            VertexAttributeSize::Vec2 => wgpu::VertexFormat::Float32x2,
            VertexAttributeSize::Vec3 => wgpu::VertexFormat::Float32x3,
            VertexAttributeSize::Vec4 => wgpu::VertexFormat::Float32x4,
            VertexAttributeSize::Float32 => wgpu::VertexFormat::Float32,
            VertexAttributeSize::Float32x2 => wgpu::VertexFormat::Float32x2,
            VertexAttributeSize::Float32x3 => wgpu::VertexFormat::Float32x3,
            VertexAttributeSize::Float32x4 => wgpu::VertexFormat::Float32x4,
        }
    }
}

impl VertexAttributeSize {
    pub fn size(&self) -> u32 {
        match self {
            VertexAttributeSize::Unknown => 0,
            VertexAttributeSize::U32 => 1,
            VertexAttributeSize::F32 => 1,
            VertexAttributeSize::Vec2 => 2,
            VertexAttributeSize::Vec3 => 3,
            VertexAttributeSize::Vec4 => 4,
            VertexAttributeSize::Float32 => 1,
            VertexAttributeSize::Float32x2 => 2,
            VertexAttributeSize::Float32x3 => 3,
            VertexAttributeSize::Float32x4 => 4,
        }
    }
}

